'''
Author: momochong0
Date: 2021-05-25 00:39:58
LastEditors: momochong0
LastEditTime: 2021-05-25 00:47:18
Description: 要推网络荣誉出品
'''
#coding=utf-8

import scrapy
import json

from infoSpider.items import BishijieItem


class BishijieSpider(scrapy.spiders.Spider):
    name = "bishijie"
    allowed_domains = ["http://www.bishijie.com"]
    start_urls = ["http://www.bishijie.com/api/news/?size=1"]

    def parse(self, response):
        #全部快讯的集合
        #file_name="info.html"
        #open(file_name,"w").write(response.body)
        jsobj = json.loads(response.body_as_unicode())

        items = []
        for item in jsobj['data']:

            item = BishijieItem()
            item['buttom'] = []
            for buttom in item.get('buttom', ''):
                item['newsflash_id'] = buttom['newsflash_id']
                item['content'] = buttom['content']
                item['issue_time'] = buttom['issue_time']

                print item['newsflash_id']
                print item['content']
                print item['issue_time']

                items.append(item)

            #item["buttom"]=jsonresponse["buttom"]
            #jsobj=json.loads(response.body)
            #content=jsobj['content']
            #print item["buttom"]
        return items
